package com.baizhi.controller;


import com.baizhi.entity.Menu;
import com.baizhi.entity.User;
import com.baizhi.service.MenuService;
import com.baizhi.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;

@Controller
@RequestMapping("menu")
public class MenuController {

    @Autowired
    MenuService menuService;

    @RequestMapping("queryAll")
    @ResponseBody
    public List<Menu> queryAll(){
        List<Menu> menuList = menuService.queryAll();
        return menuList;
    }

    @RequestMapping("search")
    @ResponseBody
    public List<Menu> search(String content){

       // System.out.println("检索的内容: "+content);
        List<Menu> menuList = null;
        try {
            menuList = menuService.search(content);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return menuList;
    }

    @RequestMapping("clearIndex")
    @ResponseBody
    public void clearIndex(){
        System.out.println("清空索引");
        menuService.clearIndex();
    }

    @RequestMapping("addIndex")
    @ResponseBody
    public void addIndex(){
        System.out.println("重构索引");
        menuService.addIndex();
    }
}

